const fp = require('lodash/fp');
const { Maybe, Container } = require('./support');

const maybe = Maybe.of([5, 6, 1]);

const ex1 = (x) => maybe.map(fp.map((item) => fp.add(item, x)));

console.log(ex1(1));

const xs = Container.of(['do', 'ray', 'me', 'fa', 'so', 'la', 'ti', 'do']);
const ex2 = () => xs.map(fp.first);

console.log(ex2());

let safeProp = fp.curry(function (x, o) {
  return Maybe.of(o[x]);
});
let user = { id: 2, name: 'Albert' };
const ex3 = () => safeProp('name')(user).map(fp.first);
console.log(ex3());

// let ex4  = function (n){
//     if(n){
//       return parseInt(n)
//     }
//   }

const ex4 = (n) => Maybe.of(n).map(parseInt);
console.log(ex4(5.9));
